package com.zc.service.impl;

import com.zc.mapper.BrokerMassageLogMapper;
import com.zc.pojo.BrokerMassageLog;
import com.zc.service.BrokerMassageLogService;
import com.zc.utils.ZcUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class BrokerMassageLogServiceImpl implements BrokerMassageLogService {

    @Autowired
    private BrokerMassageLogMapper brokerMassageLogMapper;

    @Override
    public void creat(String massageId, String massage) {
        BrokerMassageLog brokerMassageLog = new BrokerMassageLog();
        brokerMassageLog.setMassageId(massageId);
        brokerMassageLog.setMassage(massage);
        brokerMassageLog.setStatus("0");
        brokerMassageLog.setTryCount(0);
        brokerMassageLog.setNaxtRetry(ZcUtil.dateAddMinute(1));//TODO 当前时间+超时时间
        brokerMassageLog.setCreatTime(new Date());
        brokerMassageLog.setUpdateTime(new Date());
        brokerMassageLogMapper.insert(brokerMassageLog);
    }

    @Override
    public void updataStatus(String massageId, String status) {
        BrokerMassageLog brokerMassageLog = new BrokerMassageLog();
        brokerMassageLog.setMassageId(massageId);
        brokerMassageLog.setStatus(status);
        brokerMassageLog.setUpdateTime(new Date());
        brokerMassageLogMapper.updataStatusByMassageId(brokerMassageLog);
    }
}
